package windbell.domain.risk.impl;

import edu.fudan.mylang.pf.IObjectFactory;
import java.util.Date;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import windbell.domain.risk.RiskCheck;
import windbell.domain.risk.RiskCheckFromPark;
import windbell.domain.risk.RiskCheckTemplate;
import windbell.domain.risk.impl.RiskCheckSourceImpl;
import windbell.domain.risk.proxy.RiskCheckFromParkProxy;

@Entity
@DiscriminatorValue("RISKCHECKFROMPARK_TYPE")
public class RiskCheckFromParkImpl extends RiskCheckSourceImpl implements RiskCheckFromPark {
  public RiskCheckFromParkImpl() {
    super();
  }
  
  public RiskCheckFromParkImpl(final RiskCheckTemplate checkTemplate) {
    super( checkTemplate);
    
  }
  
  private String title;
  
  public String getTitle() {
    return this.title;
  }
  
  public RiskCheckFromPark setTitle(final String title) {
    this.title = title;
    return this;			
    
  }
  
  private Date dueDate;
  
  public Date getDueDate() {
    return this.dueDate;
  }
  
  public RiskCheckFromPark setDueDate(final Date dueDate) {
    this.dueDate = dueDate;
    return this;			
    
  }
  
  public String getEntityName() {
    return this.title;
  }
  
  public RiskCheck createRiskCheck(final Procedure1<? super RiskCheck> init) {
    final Procedure1<RiskCheck> _function = new Procedure1<RiskCheck>() {
        public void apply(final RiskCheck it) {
          it.setDueDate(RiskCheckFromParkImpl.this.dueDate);
          init.apply(it);
        }
      };
    RiskCheck _createRiskCheck = super.createRiskCheck(_function);
    return _createRiskCheck;
  }
  
  public static RiskCheckFromPark create(final RiskCheckTemplate checkTemplate, final IObjectFactory objectFactory) {
    windbell.domain.risk.RiskCheckFromPark riskCheckFromPark = new windbell.domain.risk.impl.RiskCheckFromParkImpl(
    	checkTemplate
    );
    objectFactory.create(riskCheckFromPark);
    return riskCheckFromPark;			
    
  }
  
  public static RiskCheckFromPark createRiskCheckFromParkImpl(final RiskCheckTemplate checkTemplate, final IObjectFactory objectFactory, final Procedure1<RiskCheckFromPark> init) {
    windbell.domain.risk.RiskCheckFromPark riskCheckFromPark = new windbell.domain.risk.impl.RiskCheckFromParkImpl(
    	checkTemplate
    );
    objectFactory.create(riskCheckFromPark);
    init.apply(riskCheckFromPark);
    return riskCheckFromPark;			
    
  }
  
  public RiskCheckFromParkProxy toProxy() {
    windbell.domain.risk.proxy.RiskCheckFromParkProxy proxy = new windbell.domain.risk.proxy.RiskCheckFromParkProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    if(this.getStatus()!=null)proxy.setStatus(this.getStatus().name());;
    return proxy;
    
  }
}
